<?php if(!defined('SABLOG_ROOT')) exit('Access Denied');?>
<div id="submenu">
	<ul>
		<li><a href="cp.php?job=tools&action=mysqlinfo" <!--{if $action == 'mysqlinfo'}--> class="focus"<!--{/if}-->><span>数据库信息</span></a></li>
		<li><a href="cp.php?job=tools&action=backup" <!--{if $action == 'backup'}--> class="focus"<!--{/if}-->><span>备份数据库</span></a></li>
		<li><a href="cp.php?job=tools&action=tools" <!--{if in_array($action,array('tools','dotools'))}--> class="focus"<!--{/if}-->><span>数据库维护</span></a></li>
		<li><a href="cp.php?job=tools&action=filelist" <!--{if in_array($action,array('filelist','checkresume'))}--> class="focus"<!--{/if}-->><span>数据文件管理</span></a></li>
		<li><a href="cp.php?job=tools&action=rssimport" <!--{if $action == 'rssimport'}--> class="focus"<!--{/if}-->><span>导入RSS数据</span></a></li>
		<li><a href="cp.php?job=tools&action=cache" <!--{if $action == 'cache'}--> class="focus"<!--{/if}-->><span>缓存管理</span></a></li>
		<li><a href="cp.php?job=tools&action=rebuild" <!--{if $action == 'rebuild'}--> class="focus"<!--{/if}-->><span>重建数据</span></a></li>
        <li><a href="cp.php?job=tools&action=searchlog" <!--{if $action == 'searchlog'}--> class="focus"<!--{/if}-->>搜索记录</a></li>
		<li><a href="cp.php?job=tools&action=adminlog" <!--{if $action == 'adminlog'}--> class="focus"<!--{/if}-->><span>后台操作记录</span></a></li>
		<li><a href="cp.php?job=tools&action=loginlog" <!--{if $action == 'loginlog'}--> class="focus"<!--{/if}-->><span>登陆记录</span></a></li>
		<li><a href="cp.php?job=tools&action=dberrorlog" <!--{if $action == 'dberrorlog'}--> class="focus"<!--{/if}-->><span>数据库出错记录</span></a></li>
	</ul>
</div>

<div id="wrap">

<h2>{$subnav}&raquo;</h2>

	<form action="cp.php?job=tools" enctype="multipart/form-data" method="POST" name="form">

<!--{if in_array($action, array('backup', 'tools'))}-->
	<!--{if $action == 'backup'}-->
	<div class="input">
		<h2>建表语句格式</h2>
		<p>
			<input type="radio" name="sqlcompat" value="" checked /> 默认<br />
			<input type="radio" name="sqlcompat" value="MYSQL40" /> MySQL 4.0.x<br />
			<input type="radio" name="sqlcompat" value="MYSQL41" /> MySQL 4.1.x/5.x
		</p>
	</div>
	<div class="input">
		<h2>字符集限定</h2>
		<p>
			<input type="radio" name="addsetnames" value="1" /> 是
			<input type="radio" name="addsetnames" value="0" checked /> 否
		</p>
	</div>
	<div class="input">
		<h2>分卷备份 - 每个文件</h2>
		<p>
			<input class="formfield" type="text" name="sizelimit" size="20" maxlength="20" value="2048" /> KB
		</p>
	</div>
	<div class="input">
		<h2>备份文件名</h2>
		<p>
			<input class="formfield" type="text" name="filename" size="40" maxlength="40" value="$backuppath" />.sql
		</p>
	</div>
	<!--{else}-->
	<div class="input">
		<h2>选择操作</h2>
		<p>
			<input type="checkbox" name="do[]" value="check" checked /> 检查表<br />
			<input type="checkbox" name="do[]" value="repair" checked /> 修复表<br />
			<input type="checkbox" name="do[]" value="analyze" checked /> 分析表<br />
			<input type="checkbox" name="do[]" value="optimize" checked /> 优化表
		</p>
	</div>
	<!--{/if}-->
	<div class="submit">
		<input type="hidden" name="action" value="$act" />
		<button type="submit">确定</button>
	</div>
<!--{elseif $action == 'filelist'}-->
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
			<td width="34%" nowrap>文件名</td>
			<td width="15%" nowrap>备份时间</td>
			<td width="15%" nowrap>修改时间</td>
			<td width="8%" nowrap>版本</td>
			<td width="8%" nowrap>卷号</td>
			<td width="8%" nowrap>文件大小</td>
			<td nowrap>操作</td>
			<td width="6%" nowrap><input name="chkall" value="on" type="checkbox" onclick="checkall(this.form)" /></td>
		</tr>
		<!--{if $noexists}-->
		<tr class="tablecell">
			<td colspan="8">目录不存在或无法访问, 请检查 $backupdir 目录.</td>
		</tr>
		<!--{else}-->
			<!--{loop $dbfiles $dbfile}-->
				<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
		<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
			<td><a href="$backupdir/$dbfile[filename]" title="右键另存为保存该文件">$dbfile[filename]</a></td>
			<td nowrap>$dbfile[bktime]</td>
			<td nowrap>$dbfile[mtime]</td>
			<td nowrap>$dbfile[version]</td>
			<td nowrap>$dbfile[volume]</td>
			<td nowrap>$dbfile[filesize]</td>
			<td nowrap><!--{if $dbfile['volume'] == '1'}--><a href="cp.php?job=tools&action=checkresume&sqlfile=$dbfile[filepath]">导入</a><!--{else}-->无<!--{/if}--></td>
			<td nowrap><input type="checkbox" name="sqlfile[{$backupdir}/{$dbfile[filename]}]" value="1" /></td>
		</tr>
			<!--{/loop}-->
		<!--{/if}-->
		<tr class="tablecell">
			<td colspan="8"><b>共有{$file_i}个备份文件</b></td>
		</tr>
	</table>
	<div class="submit">
		<input type="hidden" name="action" value="deldbfile" />
		<button type="submit">删除所选文件</button>
	</div>
<!--{elseif $action == 'mysqlinfo'}-->
	<h2>MYSQL数据库信息&raquo;</h2>
	<ul class="info">
		<li><u>版本:</u>$mysql_version</li>
		<li><u>运行时间:</u>$mysql_runtime</li>
	</ul>
	<h2>Sablog-X数据表&raquo;</h2>
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
			<td width="20%">名称</td>
			<td width="20%">创建时间</td>
			<td width="20%">最后更新时间</td>
			<td width="10%">记录数</td>
			<td width="10%">数据</td>
			<td width="10%">索引</td>
			<td width="10%">碎片</td>
		</tr>
		<!--{loop $sablog_table $sablog}-->
			<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
		<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
			<td>$sablog[Name]</td>
			<td nowrap>$sablog[Create_time]</td>
			<td nowrap>$sablog[Update_time]</td>
			<td nowrap>$sablog[Rows]</td>
			<td nowrap>$sablog[Data_length]</td>
			<td nowrap>$sablog[Index_length]</td>
			<td nowrap>$sablog[Data_free]</td>
		</tr>
		<!--{/loop}-->
		<tr class="tablecell">
			<td colspan="3"><b>共计:{$sablog_table_num}个数据表</b></td>
			<td><b>$sablog_table_rows</b></td>
			<td><b>$sablog_data_size</b></td>
			<td><b>$sablog_index_size</b></td>
			<td><b>$sablog_free_size</b></td>
		</tr>
	</table>
	<br />
	<h2>其他数据表&raquo;</h2>
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
			<td width="20%">名称</td>
			<td width="20%">创建时间</td>
			<td width="20%">最后更新时间</td>
			<td width="10%">记录数</td>
			<td width="10%">数据</td>
			<td width="10%">索引</td>
			<td width="10%">碎片</td>
		</tr>
	<!--{loop $other_table $other}-->
		<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
		<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
			<td>$other[Name]</td>
			<td nowrap>$other[Create_time]</td>
			<td nowrap>$other[Update_time]</td>
			<td nowrap>$other[Rows]</td>
			<td nowrap>$other[Data_length]</td>
			<td nowrap>$other[Index_length]</td>
			<td nowrap>$other[Data_free]</td>
		</tr>
	<!--{/loop}-->
		<tr class="tablecell">
			<td colspan="3"><b>共计:{$other_table_num}个数据表</b></td>
			<td><b>$other_table_rows</b></td>
			<td><b>$other_data_size</b></td>
			<td><b>$other_index_size</b></td>
			<td><b>$other_free_size</b></td>
		</tr>
	</table>

<!--{elseif $action == 'dotools'}-->
	<!--{loop $dodb $do}-->
		<div style="width:23%;margin-right:15px;float:left;">
			<h2>$do[name]表&raquo;</h2>
			<ul class="info">
				<!--{loop $tabledb $table}-->
					<!--{if $table['do'] == $do['do']}-->
						<li><em>$table[table]:</em>$table[result]</li>
					<!--{/if}-->
				<!--{/loop}-->
			</ul>
		</div>
	<!--{/loop}-->

<!--{elseif $action == 'checkresume' && $dbimport}-->
	<h2>导入备份数据&raquo;</h2>
	<div class="input">
		<h2>导入文件</h2>
		<p>
			$sqlfile<br />
			<span class="describe">恢复功能将覆盖原来的数据,您确认要导入备份数据?</span>
		</p>
	</div>
	<div class="submit">
		<input type="hidden" name="action" value="resume" />
		<input type="hidden" name="sqlfile" value="$sqlfile" />
		<button type="submit">确认</button>
	</div>
<!--{elseif $action == 'rssimport'}-->
	<div class="input">
		<h2>选择目标分类</h2>
		<p>
			<select name="cid" id="cid">
				<option value="" selected>== 选择分类 ==</option>
				<!--{loop $catedb $cate}-->
				<option value="$cate[cid]">$cate[name]</option>
				<!--{/loop}-->
			</select>
		</p>
	</div>
	<div class="input">
		<h2>选择文章作者</h2>
		<p>
			<select name="uid" id="uid">
				<option value="" selected>== 选择作者 ==</option>
				<!--{loop $userdb $user}-->
				<option value="$user[userid]">$user[username]</option>
				<!--{/loop}-->
			</select>
		</p>
	</div>
	<div class="input">
		<h2>选择XML文件</h2>
		<p>
			<input class="formfield" type="file" name="xmlfile" /><br />
			<span class="describe">允许文件类型:xml</span>
		</p>
	</div>
	<div class="submit">
		<input type="hidden" name="action" value="importrss" />
		<button type="submit">确认</button>
	</div>
<!--{elseif $action == 'cache'}-->
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
			<td>缓存名称</td>
			<td>生成时间</td>
			<td>修改时间</td>
			<td>缓存大小</td>
		</tr>
	<!--{loop $cachedb $cache}-->
		<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
		<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
			<td>$cache[desc]</td>
			<td>$cache[ctime]</td>
			<td>$cache[mtime]</td>
			<td>$cache[size]</td>
		</tr>
	<!--{/loop}-->
	</table>
	<div class="submit">
		<input type="hidden" name="action" value="updateall" />
		<button type="submit">更新所有缓存</button>
	</div>
<!--{elseif $action == 'rebuild'}-->
		<div class="input">
			<h2>更新首页侧栏的统计数据</h2>
			<p>
				<input type="hidden" name="action" value="dostatsdata" />
				<button type="submit">确认</button>
			</p>
		</div>
	</form>
	<form action="cp.php?job=tools" method="post">
		<div class="input">
			<h2>更新所有分类的文章数</h2>
			<p>
				<input type="hidden" name="action" value="docatedata" />
				<button type="submit">确认</button>
			</p>
		</div>
	</form>
	<form action="cp.php?job=tools" method="post">
		<div class="input">
			<h2>更新后台用户发表数量</h2>
			<p>
				<input type="hidden" name="action" value="doadmindata" />
				<button type="submit">确认</button>
			</p>
		</div>
	</form>
	<form action="cp.php?job=tools" method="post">
		<div class="input">
			<h2>更新所有文章数据</h2>
			<p>
				<input type="hidden" name="action" value="doarticledata" />
				循环更新数量: <input class="formfield" type="text" name="percount" value="200" size="5" /> <button type="submit">确认</button><br />
				<span class="describe">更新所有文章中的评论数、引用数及附件信息. 建议经常定期执行, 配合附件管理中的附件修复操作, 可以提高数据准确性和程序的执行效率.</span>
			</p>
		</div>
	</form>
	<form action="cp.php?job=tools" method="post">
		<div class="input">
			<h2>重建附件缩略图</h2>
			<p>
				<input type="hidden" name="action" value="dothumbdata" />
				循环更新数量: <input class="formfield" type="text" name="percount" value="20" size="5" /> <button type="submit">确认</button><br />
				<span class="describe">重新按照现在设定的缩略图尺寸重建所有附件图像的缩略图。通常用于你更改了缩略图尺寸并希望更新全部附件的情况下。这个操作会耗费一定服务器资源。</span>
			</p>
		</div>

<!--{elseif $action == 'searchlog'}-->
	<h2>搜索记录&raquo;</h2>
	<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
		<tr class="tdbheader">
		  <td width="25%"><b>关键字</b></td>
		  <td width="25%"><b>搜索时间</b></td>
		  <td width="25%"><b>搜索结果</b></td>
		  <td width="25%"><b>IP地址</b></td>
		</tr>
		<!--{loop $searchdb $search}-->
			<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
		<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
          <td nowrap="nowrap">$search[keywords]</td>
          <td nowrap="nowrap">$search[dateline]</td>
          <td nowrap="nowrap">$search[totals] 条记录</td>
          <td nowrap="nowrap">$search[ipaddress]</td>
        </tr>
		<!--{/loop}-->
			<tr class="tablecell">
			  <td colspan="4"><div class="records">记录:$total</div>
				<div class="multipage">$multipage</div></td>
			</tr>
	</table>
	<div class="submit">
		<input type="hidden" name="action" value="delsearchlog">
		<button type="submit">清空所有搜索记录</button>
	</div>
<!--{elseif in_array($action, array('adminlog', 'loginlog', 'deladminlog', 'delloginlog', 'dberrorlog', 'deldberrorlog'))}-->
	<!--{if $action == 'adminlog'}-->
		<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			<tr class="tdbheader">
				<td>用户</td>
				<td>IP地址</td>
				<td>访问时间</td>
				<td>访问模块</td>
				<td>操作</td>
			</tr>
		<!--{if $logdb}-->
			<!--{loop $logdb $log}-->
				<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
				<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
					<td>$log[2]</td>
					<td>$log[3]</td>
					<td>$log[1]</td>
					<td><a href="cp.php?job=$log[5]">$log[5]</a></td>
					<td>$log[4]</td>
				</tr>
			<!--{/loop}-->
		<!--{else}-->
			<tr class="tablecell">
				<td colspan="5">没有操作记录</td>
			</tr>
		<!--{/if}-->
			<tr class="tablecell">
			  <td colspan="5"><div class="records">记录:$total</div>
				<div class="multipage">$multipage</div></td>
			</tr>
		</table>
	<!--{elseif $action == 'loginlog'}-->
		<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			<tr class="tdbheader">
				<td>用户名</td>
				<td>登陆时间</td>
				<td>IP地址</td>
				<td>登陆结果</td>
			</tr>
		<!--{if $logdb}-->
			<!--{loop $logdb $log}-->
				<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
				<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
					<td>$log[1]</td>
					<td>$log[2]</td>
					<td>$log[3]</td>
					<td>$log[4]</td>
				</tr>
			<!--{/loop}-->
		<!--{else}-->
			<tr class="tablecell">
				<td colspan="5">没有登陆记录</td>
			</tr>
		<!--{/if}-->
			<tr class="tablecell">
			  <td colspan="4"><div class="records">记录:$total</div>
				<div class="multipage">$multipage</div></td>
			</tr>
		</table>
	<!--{elseif $action == 'dberrorlog'}-->
		<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
			<tr class="tdbheader">
				<td width="22%">信息:</td>
				<td>错误描述</td>
				<td>SQL语句</td>
			</tr>
		<!--{if $logdb}-->
			<!--{loop $logdb $log}-->
				<!--{eval $thisbg = isset($thisbg) && $thisbg == 'tablecell' ? 'tablecell2' : 'tablecell';}-->
				<tr class="$thisbg" onmouseover="this.className='cellfocus';" onmouseout="this.className='$thisbg';">
					<td nowrap>
					出错时间:$log[1]<br />
					访问地址:$log[2]<br />
					访问文件:$log[3]
					</td>
					<td class="break">$log[4]</td>
					<td class="break">$log[5]</td>
				</tr>
			<!--{/loop}-->
		<!--{else}-->
			<tr class="tablecell">
				<td colspan="5">没有出错记录</td>
			</tr>
		<!--{/if}-->
			<tr class="tablecell">
			  <td colspan="5"><div class="records">记录:$total</div>
				<div class="multipage">$multipage</div></td>
			</tr>
		</table>
	<!--{/if}-->

		<div class="submit">
			<input type="hidden" name="action" value="del{$action}" />
			<button onclick="if(!confirm('此操作会只保留最新的100条{$opname},而将其他更早的记录删除.确定吗?')) return false;" type="submit">删除多余{$opname}</button>
		</div>

<!--{/if}-->
</form>